News All Tests
Current file: /home/estudydev/workspace/MSP09/web/news/tests/class.newscategoryforum.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 8
0.92 %0.92%
0.92% 2 / 217
 
NewsCategoryForum
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 8
0.46 %0.46%
0.46% 1 / 216
 public function __construct($catID, $courses, $userID, $categorySettings = NULL, $installCacheObject = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
 public function echoNews($courseID, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 public function isInstalled($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function canSelectPeriod()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getNewsHeaderTitle($courseID = NULL, $type = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 8
 public function createQueryCacheObject($from, $to, $lastvisit, $usergroup, $courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 82
 protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 77
 protected function echoNewsEntry($entry, $courseID, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 36


       1                 : <?php                                                                                                                                                                                         
       2                 : /*--------------------------------------------------------------------------+                                                                                                                 
       3                 : This file is part of eStudy.                                                                                                                                                                  
       4                 : news/classes/class.NewsCategoryForum.inc.php                                                                                                                                                  
       5                 : - Modulgruppe:  News                                                                                                                                                                          
       6                 : - Beschreibung: Klasse für die News-Kategorie Forum.                                                                                                                                         
       7                 : - Version:      1.1.2.4, 24/01/08                                                                                                                                                             
       8                 : - Autor(en):    Corinna Kropf <corinna.kropf@mni.fh-giessen.de>                                                                                                                               
       9                 : +---------------------------------------------------------------------------+                                                                                                                 
      10                 : This program is free software; you can redistribute it and/or                                                                                                                                 
      11                 : modify it under the terms of the GNU General Public License                                                                                                                                   
      12                 : as published by the Free Software Foundation; either version 2                                                                                                                                
      13                 : of the License, or any later version.                                                                                                                                                         
      14                 : +---------------------------------------------------------------------------+                                                                                                                 
      15                 : This program is distributed in the hope that it will be useful,                                                                                                                               
      16                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                                                                
      17                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                                                                 
      18                 : GNU General Public License for more details.                                                                                                                                                  
      19                 : You should have received a copy of the GNU General Public License                                                                                                                             
      20                 : along with this program; if not, write to the Free Software                                                                                                                                   
      21                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                                                                   
      22                 : +--------------------------------------------------------------------------*/                                                                                                                 
      23                 :                                                                                                                                                                                               
      24               1 : require_once ("class.newscategory.inc.php");                                                                                                                                                  
      25                 :                                                                                                                                                                                               
      26                 : /**                                                                                                                                                                                           
      27                 :  * Klasse für die News-Kategorie Forum.                                                                                                                                                      
      28                 :  * @package eStudy.News                                                                                                                                                                       
      29                 :  * @version 1.1.2.4, 24/01/08                                                                                                                                                                 
      30                 :  * @author  Corinna Kropf <corinna.kropf@mni.fh-giessen.de>                                                                                                                                   
      31                 :  */                                                                                                                                                                                           
      32               1 : class NewsCategoryForum extends NewsCategory                                                                                                                                                  
      33                 : {                                                                                                                                                                                             
      34                 :     /**                                                                                                                                                                                       
      35                 :      * Cache Objekt zur Abfrage von Modulinstallationen (Performance Tweak)                                                                                                                   
      36                 :      * @var array                                                                                                                                                                             
      37                 :      */                                                                                                                                                                                       
      38                 :     private $installCacheObject;                                                                                                                                                              
      39                 :    /**                                                                                                                                                                                        
      40                 :      * Flag fuer die Anzeige der News-Eintraege                                                                                                                                               
      41                 :      * @var bool                                                                                                                                                                              
      42                 :      */                                                                                                                                                                                       
      43                 :     private $dark;                                                                                                                                                                            
      44                 :    /**                                                                                                                                                                                        
      45                 :      * HTML-Template                                                                                                                                                                          
      46                 :      * @var Template                                                                                                                                                                          
      47                 :      */                                                                                                                                                                                       
      48                 :     private $forumThreadTemplate;                                                                                                                                                             
      49                 :    /**                                                                                                                                                                                        
      50                 :      * HTML-Template                                                                                                                                                                          
      51                 :      * @var Template                                                                                                                                                                          
      52                 :      */                                                                                                                                                                                       
      53                 :     private $forumThreadPostTemplate;                                                                                                                                                         
      54                 :        /**                                                                                                                                                                                    
      55                 :      * @var int                                                                                                                                                                               
      56                 :      */                                                                                                                                                                                       
      57                 :     private $userID;                                                                                                                                                                          
      58                 :     /**                                                                                                                                                                                       
      59                 :      * Konstruktor                                                                                                                                                                            
      60                 :      * @param $userID int                                                                                                                                                                     
      61                 :      */                                                                                                                                                                                       
      62                 :     public function __construct($catID, $courses, $userID, $categorySettings = null, $installCacheObject = null)                                                                              
      63                 :     {                                                                                                                                                                                         
      64               0 :         parent::__construct($catID, $courses, $categorySettings);                                                                                                                             
      65               0 :         $this->installCacheObject = $installCacheObject;                                                                                                                                      
      66               0 :         $this->userID = $userID;                                                                                                                                                              
      67               0 :         $this->forumThreadTemplate = new Template(PATH_TO_ROOT."news/templates/newsforumthread.html");                                                                                        
      68               0 :         $this->forumThreadPostTemplate = new Template(PATH_TO_ROOT."news/templates/newsforumthreadpost.html");                                                                                
      69               0 :     }                                                                                                                                                                                         
      70                 :    /**                                                                                                                                                                                        
      71                 :      * Überschreibt die Methode der Oberklasse,                                                                                                                                              
      72                 :      * um weitere Initialisierungen vor der Ausgabe zu machen.                                                                                                                                
      73                 :      * @see NewsCategory                                                                                                                                                                      
      74                 :      */                                                                                                                                                                                       
      75                 :     public function echoNews($courseID, $usergroup = null)                                                                                                                                    
      76                 :     {                                                                                                                                                                                         
      77               0 :         $this->dark = false;                                                                                                                                                                  
      78               0 :         parent::echoNews($courseID, $usergroup);                                                                                                                                              
      79               0 :     }                                                                                                                                                                                         
      80                 :     /**                                                                                                                                                                                       
      81                 :      * Muss angepasst werden, falls Modulgruppen umbenannt werden!                                                                                                                            
      82                 :      * @see NewsCategory                                                                                                                                                                      
      83                 :      */                                                                                                                                                                                       
      84                 :     public function isInstalled($courseID)                                                                                                                                                    
      85                 :     {                                                                                                                                                                                         
      86               0 :         return (Utilities::isInstalled("forum", $courseID, $this->installCacheObject)                                                                                                         
      87               0 :                 || Utilities::isInstalled("fotoforum", $courseID, $this->installCacheObject));                                                                                                
      88                 :     }                                                                                                                                                                                         
      89                 :     /**                                                                                                                                                                                       
      90                 :      * @see NewsCategory                                                                                                                                                                      
      91                 :      */                                                                                                                                                                                       
      92                 :     public function canSelectPeriod() {                                                                                                                                                       
      93               0 :         return true;                                                                                                                                                                          
      94                 :     }                                                                                                                                                                                         
      95                 :     /**                                                                                                                                                                                       
      96                 :      * @see NewsCategory                                                                                                                                                                      
      97                 :      */                                                                                                                                                                                       
      98                 :     public function getNewsHeaderTitle($courseID = null, $type = null) {                                                                                                                      
      99               0 :         if(isset($this->news))                                                                                                                                                                
     100               0 :         {                                                                                                                                                                                     
     101               0 :             $newsCount = $this->news["count"];                                                                                                                                                
     102               0 :             if ($newsCount > 1) $title = sprintf( $this->translate->_("%1\$s Forenbeitr&auml;ge"), $newsCount);                                                                               
     103               0 :             elseif ($newsCount == 1) $title = $this->translate->_("1 Forumbeitrag");                                                                                                          
     104               0 :         }                                                                                                                                                                                     
     105               0 :         else $title = $this->translate->_("Keine neuen Forenbeitr&auml;ge");                                                                                                                  
     106                 :                                                                                                                                                                                               
     107               0 :         return $title;                                                                                                                                                                        
     108                 :     }                                                                                                                                                                                         
     109                 :                                                                                                                                                                                               
     110                 :     public function createQueryCacheObject($from, $to, $lastvisit, $usergroup, $courseID) {                                                                                                   
     111               0 :         global $db;                                                                                                                                                                           
     112               0 :         $userID = data::toMysql($_SESSION["userid"]);                                                                                                                                         
     113                 :         $sql =   "SELECT courseID FROM forum_ban "                                                                                                                                            
     114               0 :                 ."WHERE userID='".Data::toMysql($this->userID)."' "                                                                                                                           
     115               0 :                 ."AND (banexpire>".time() ." OR banexpire=0)";                                                                                                                                
     116               0 :         $bans = $db->get_col($sql);                                                                                                                                                           
     117               0 :         $courseBans = null;                                                                                                                                                                   
     118               0 :         if ($bans != null) {                                                                                                                                                                  
     119               0 :             $courseBans = array();                                                                                                                                                            
     120               0 :             foreach ($bans as $ban)                                                                                                                                                           
     121               0 :                 $courseBans[$ban->courseID] = "banned";                                                                                                                                       
     122               0 :         }                                                                                                                                                                                     
     123                 :                                                                                                                                                                                               
     124               0 :         $this->queryCacheObject = array();                                                                                                                                                    
     125                 :                                                                                                                                                                                               
     126               0 :         $timefrom = $this->getPeriod($courseID, $from) ;                                                                                                                                      
     127               0 :         $timeto = $to;                                                                                                                                                                        
     128                 :                                                                                                                                                                                               
     129                 :         // Alle Kurse des Benutzers und deren Kurs-Berechtugungen                                                                                                                             
     130               0 :         if ($usergroup != ADMIN) {                                                                                                                                                            
     131                 :             $sql = "SELECT courseID, IF(differentUsergroup>0, differentUsergroup, "                                                                                                           
     132                 :                 . $usergroup                                                                                                                                                                  
     133               0 :                 . ") AS usergroup FROM user_course JOIN courses ON courseID=ID WHERE userID='$userID' AND closed='0' "                                                                        
     134               0 :                 ."UNION SELECT 0 AS courseID, $usergroup AS usergroup";                                                                                                                       
     135               0 :         } else {                                                                                                                                                                              
     136                 :             $sql = "SELECT ID AS courseID, 1 AS usergroup FROM courses WHERE closed = 0 "                                                                                                     
     137               0 :                 ."UNION SELECT 0 AS courseID, $usergroup AS usergroup";                                                                                                                       
     138                 :         }                                                                                                                                                                                     
     139               0 :         $courseUserGroupResults = $db->get_results($sql);                                                                                                                                     
     140               0 :             $courseGroups = array();                                                                                                                                                          
     141               0 :             foreach ($courseUserGroupResults as $courseUserGroupResult)                                                                                                                       
     142               0 :                 $courseGroups[$courseUserGroupResult->courseID] = $courseUserGroupResult->usergroup;                                                                                          
     143                 :            // print_r($courseUserGroupResult);return null;                                                                                                                                    
     144                 :             // Hier werden zunächst alle Boards ausgelesen, da der Benutzer unterschiedliche Berechtigungen                                                                                  
     145                 :             // in einem Kurs haben kann. Die Berechtigung für den Boardzugriff wird später geprüft.                                                                                        
     146               0 :             $boardsNotReadableByStudents = null;                                                                                                                                              
     147               0 :             if ($usergroup == STUDENT || $usergroup == ALUMNUS || $usergroup == SCHUELER || $usergroup == GAST) {                                                                             
     148               0 :                 $viewableGalleries = $db->get_col("SELECT album_id FROM photogallery_rights WHERE usr_id='"                                                                                   
     149               0 :                 .Data::toMysql($this->userID)."' AND (view=1 OR admin=1)");                                                                                                                   
     150               0 :                 if ($db->num_rows) $viewableGalleries = "AND album_id NOT IN (".implode(",", $viewableGalleries) .") ";                                                                       
     151               0 :                 else $viewableGalleries = "";                                                                                                                                                 
     152               0 :                 $results = $db->get_results("SELECT forum_groupboard.boardid "                                                                                                                
     153                 :                 ."FROM forum_groupboard JOIN forum_board ON forum_groupboard.boardid=forum_board.boardid "                                                                                    
     154               0 :                 ."WHERE accessmask LIKE '0%' AND is_photogallery=0 "."GROUP BY boardid "."UNION "."SELECT album_id "                                                                          
     155               0 :                 ."FROM photogallery_rights "."WHERE usr_id=0 "."AND view=0 $viewableGalleries"."GROUP BY album_id");                                                                          
     156               0 :                 if ($db->num_rows) {                                                                                                                                                          
     157               0 :                 $boardsNotReadableByStudents = array();                                                                                                                                       
     158               0 :                 foreach ($results as $result)                                                                                                                                                 
     159               0 :                     $boardsNotReadableByStudents[$result->boardid] = $result->boardid;                                                                                                        
     160               0 :                 }                                                                                                                                                                             
     161               0 :             }                                                                                                                                                                                 
     162                 :             $sql = "select b.categoryid, b.boardid, b.is_photogallery, p.posttime, p.postlastedittime, b.boardname, t.threadtopic, p.postid, p.posttext, "                                    
     163                 :                 ."p.userID, t.threadid, l.lastvisitedtime FROM forum_post p "                                                                                                                 
     164               0 :                 ."LEFT JOIN forum_thread t ON (t.threadid = p.threadid) "                                                                                                                     
     165               0 :                 ."LEFT JOIN forum_lastvisited l ON (l.boardid = t.boardid AND l.userID =".Data::toMysql($this->userID).") "                                                                   
     166               0 :                 ."LEFT JOIN forum_board b ON (b.boardid = t.boardid) "                                                                                                                        
     167                 :                 //."WHERE ( ((posttime>='$timefrom') AND (posttime<='$timeto')) OR "                                                                                                          
     168               0 :                 ."WHERE ( (posttime>='$timefrom') OR "                                                                                                                                        
     169                 :                 //."          ((postlastedittime>='$timefrom') AND (postlastedittime<='$timeto')) ) "                                                                                         
     170               0 :                 ."          (postlastedittime>='$timefrom') ) "                                                                                                                               
     171               0 :                 ." AND boarddisabled=0 ";                                                                                                                                                     
     172               0 :             if ($usergroup != ADMIN)                                                                                                                                                          
     173               0 :                 $sql .= "AND categoryid IN (SELECT courseID FROM user_course JOIN courses ON (courseID=ID) WHERE userID='$userID' AND closed='0' UNION SELECT 0) ";                           
     174               0 :             $sql .= "ORDER BY posttime DESC";                                                                                                                                                 
     175                 :         //$text = data::toMysql($sql);                                                                                                                                                        
     176                 :         //$db->query("insert into temp(str) values('$text')");                                                                                                                                
     177               0 :         $posts = $db->get_results($sql);                                                                                                                                                      
     178                 :                                                                                                                                                                                               
     179               0 :         $boards = array();                                                                                                                                                                    
     180               0 :         if ($posts != null) {                                                                                                                                                                 
     181               0 :             foreach ($posts as $post) {                                                                                                                                                       
     182                 :                 // Kurs geschlossen                                                                                                                                                           
     183               0 :                 if (!array_key_exists($post->categoryid, $courseGroups))                                                                                                                      
     184               0 :                     continue;                                                                                                                                                                 
     185               0 :                 if ($post->categoryid == 0)                                                                                                                                                   
     186               0 :                     $courseUserGroup = $usergroup;                                                                                                                                            
     187                 :                 else                                                                                                                                                                          
     188               0 :                     $courseUserGroup = $courseGroups[$post->categoryid];                                                                                                                      
     189                 :                 // array: board,thread,postid ==> boardtitle,posttext,userid,posttitle                                                                                                        
     190                 :                 // Boards auf die Benutzer keinen Zugriff hat entfernen                                                                                                                       
     191               0 :                 if ($courseUserGroup == STUDENT || $courseUserGroup == ALUMNUS || $courseUserGroup == SCHUELER || $courseUserGroup == GAST) {                                                 
     192               0 :                     if (is_array($boardsNotReadableByStudents) && isset($boardsNotReadableByStudents[$post->boardid]))                                                                        
     193               0 :                         continue;                                                                                                                                                             
     194               0 :                 }                                                                                                                                                                             
     195               0 :                 if (is_array($courseBans) && array_key_exists($post->categoryid, $courseBans))                                                                                                
     196               0 :                         continue;                                                                                                                                                             
     197                 :                                                                                                                                                                                               
     198               0 :                 if (isset($boards[$post->categoryid]['count']))                                                                                                                               
     199               0 :                     $boards[$post->categoryid]['count'] = $boards[$post->categoryid]['count'] + 1;                                                                                            
     200                 :                 else                                                                                                                                                                          
     201               0 :                     $boards[$post->categoryid]['count'] = 1;                                                                                                                                  
     202                 :                                                                                                                                                                                               
     203               0 :                 $boards[$post->categoryid][$post->boardid]['boardName'] = $post->boardname;                                                                                                   
     204               0 :                 $boards[$post->categoryid][$post->boardid]['isPhotoGallery'] = $post->is_photogallery;                                                                                        
     205               0 :                 $boards[$post->categoryid][$post->boardid]['threads'][$post->threadid]['threadTopic'] = $post->threadtopic;                                                                   
     206               0 :                 $boards[$post->categoryid][$post->boardid]['threads'][$post->threadid]['threadID'] = $post->threadid;                                                                         
     207               0 :                 $boards[$post->categoryid][$post->boardid]['threads'][$post->threadid]['lastVisitedTime'] = $post->lastvisitedtime;                                                           
     208               0 :                 $boards[$post->categoryid][$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['postid'] = $post->postid;                                                     
     209               0 :                 $boards[$post->categoryid][$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['postTime'] = $post->posttime;                                                 
     210               0 :                 $boards[$post->categoryid][$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['postText'] = $post->posttext;                                                 
     211               0 :                 $boards[$post->categoryid][$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['userID'] = $post->userID;                                                     
     212               0 :                 $boards[$post->categoryid][$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['postLastEditTime'] = $post->postlastedittime;                                 
     213               0 :                 $this->users[$boards[$post->categoryid][$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['userID']] =                                                      
     214               0 :                     $boards[$post->categoryid][$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['userID'];                                                                 
     215               0 :             }                                                                                                                                                                                 
     216               0 :         }                                                                                                                                                                                     
     217                 :                                                                                                                                                                                               
     218               0 :         $this->queryCacheObject["messagesPerPage"] = $db->get_var("SELECT keyvalue FROM forum_registry WHERE keyname='vars_m_amount'");                                                       
     219               0 :         $this->queryCacheObject["cacheObject"] = $boards;                                                                                                                                     
     220               0 :         return true;                                                                                                                                                                          
     221                 :     }                                                                                                                                                                                         
     222                 :                                                                                                                                                                                               
     223                 :     /**                                                                                                                                                                                       
     224                 :      * @see NewsCategory                                                                                                                                                                      
     225                 :      */                                                                                                                                                                                       
     226                 :     protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = null)  {                                                                                               
     227                 :         // Neue Forenbeitraege                                                                                                                                                                
     228               0 :         if (isset($courseID) && isset($from) && isset($to) /*&& isset($this->coursePreferences)*/ && isset($usergroup) && isset($this->userID))                                               
     229               0 :         {                                                                                                                                                                                     
     230               0 :             if (!is_numeric($courseID) || !is_numeric($to) || !is_numeric($from) || !is_numeric($usergroup))                                                                                  
     231               0 :                 return null;                                                                                                                                                                  
     232                 :                                                                                                                                                                                               
     233               0 :             $this->news = null;                                                                                                                                                               
     234                 :                                                                                                                                                                                               
     235               0 :             if ($_SESSION["course"] == 0 || $this->queryCacheObject != null) {                                                                                                                
     236               0 :                 if ($this->queryCacheObject == null)                                                                                                                                          
     237               0 :                     $this->createQueryCacheObject($from, $to, $lastvisit, $usergroup, $courseID);                                                                                             
     238                 :                                                                                                                                                                                               
     239               0 :                 if ($this->queryCacheObject == null)                                                                                                                                          
     240               0 :                     return null;                                                                                                                                                              
     241               0 :                 $cacheObject =  $this->queryCacheObject["cacheObject"];                                                                                                                       
     242               0 :                 if (!array_key_exists($courseID, $cacheObject))                                                                                                                               
     243               0 :                     return null;                                                                                                                                                              
     244               0 :                 $boards = $cacheObject[$courseID];                                                                                                                                            
     245               0 :                 $boardCount = count($boards);                                                                                                                                                 
     246               0 :                 if ($boardCount == 0)                                                                                                                                                         
     247               0 :                     $this->news = null;                                                                                                                                                       
     248                 :                 else {                                                                                                                                                                        
     249               0 :                     $this->news["messagesPerPage"] = $this->queryCacheObject["messagesPerPage"];                                                                                              
     250               0 :                     $this->news["data"] = $boards;                                                                                                                                            
     251               0 :                     $this->news["count"] = $boards['count'];                                                                                                                                  
     252                 :                 }                                                                                                                                                                             
     253                 :                                                                                                                                                                                               
     254               0 :                 return $this->news;                                                                                                                                                           
     255                 :             }                                                                                                                                                                                 
     256                 :                                                                                                                                                                                               
     257               0 :             global $db;                                                                                                                                                                       
     258                 :             $sql =   "SELECT userID FROM forum_ban "                                                                                                                                          
     259               0 :                     ."WHERE userID='".Data::toMysql($this->userID)."' "                                                                                                                       
     260               0 :                     ."AND courseID IN (-1, ".Data::toMysql($courseID).") "                                                                                                                    
     261               0 :                     ."AND (banexpire>".time() ." OR banexpire=0)";                                                                                                                            
     262               0 :             if(!is_array($db->get_col($sql)))                                                                                                                                                 
     263               0 :             {                                                                                                                                                                                 
     264               0 :                 $this->news = array();                                                                                                                                                        
     265                 :                                                                                                                                                                                               
     266                 :                 //$time = $this->getPeriod($courseID, $lastvisit);                                                                                                                            
     267               0 :                 $timefrom = $this->getPeriod($courseID, $from) ;                                                                                                                              
     268               0 :                 $timeto = $to;                                                                                                                                                                
     269                 :                                                                                                                                                                                               
     270                 :                 // Boards auslesen, die für Studenten nicht sichtbar sind                                                                                                                    
     271               0 :                 $boardsNotReadableByStudents = "";                                                                                                                                            
     272               0 :                 if ($usergroup == STUDENT || $usergroup == ALUMNUS || $usergroup == SCHUELER || $usergroup == GAST) {                                                                         
     273               0 :                     $viewableGalleries = $db->get_col("SELECT album_id FROM photogallery_rights WHERE usr_id='"                                                                               
     274               0 :                     .Data::toMysql($this->userID)."' AND (view=1 OR admin=1)");                                                                                                               
     275               0 :                     if ($db->num_rows) $viewableGalleries = "AND album_id NOT IN (".implode(",", $viewableGalleries) .") ";                                                                   
     276               0 :                     else $viewableGalleries = "";                                                                                                                                             
     277               0 :                     $results = $db->get_col("SELECT forum_groupboard.boardid "                                                                                                                
     278                 :                     ."FROM forum_groupboard JOIN forum_board ON forum_groupboard.boardid=forum_board.boardid "                                                                                
     279               0 :                     ."WHERE accessmask LIKE '0%' "."AND is_photogallery=0 "."GROUP BY boardid "."UNION "."SELECT album_id "                                                                   
     280               0 :                     ."FROM photogallery_rights "."WHERE usr_id=0 "."AND view=0 $viewableGalleries"."GROUP BY album_id");                                                                      
     281               0 :                     if ($db->num_rows) $boardsNotReadableByStudents = "AND b.boardid NOT IN (".implode(",", $results) .") ";                                                                  
     282               0 :                 }                                                                                                                                                                             
     283                 :                 $sql = "select b.boardid, b.is_photogallery, p.posttime, p.postlastedittime, b.boardname, t.threadtopic, p.postid, p.posttext, "                                              
     284                 :                         ."p.userID, t.threadid, l.lastvisitedtime FROM forum_post p "                                                                                                         
     285               0 :                         ."LEFT JOIN forum_thread t ON (t.threadid = p.threadid) "                                                                                                             
     286               0 :                         ."LEFT JOIN forum_lastvisited l ON (l.boardid = t.boardid AND l.userID =".Data::toMysql($this->userID).") "                                                           
     287               0 :                         ."LEFT JOIN forum_board b ON (b.boardid = t.boardid) "                                                                                                                
     288                 :                         //."WHERE ( ((posttime>='$timefrom') AND (posttime<='$timeto')) OR "                                                                                                  
     289               0 :                         ."WHERE ( (posttime>='$timefrom') OR "                                                                                                                                
     290                 :                         //."          ((postlastedittime>='$timefrom') AND (postlastedittime<='$timeto')) ) "                                                                                 
     291               0 :                         ."          (postlastedittime>='$timefrom') ) "                                                                                                                       
     292               0 :                         ."AND categoryid='".Data::toMysql($courseID)."' AND boarddisabled=0 "                                                                                                 
     293               0 :                         ."$boardsNotReadableByStudents "                                                                                                                                      
     294               0 :                         ."ORDER BY posttime DESC";                                                                                                                                            
     295                 :                                                                                                                                                                                               
     296               0 :                 $posts = $db->get_results($sql);                                                                                                                                              
     297               0 :                 $postsTotal = 0;                                                                                                                                                              
     298               0 :                 $boards = array();                                                                                                                                                            
     299               0 :                 if ($posts != null) {                                                                                                                                                         
     300               0 :                     foreach ($posts as $post) {                                                                                                                                               
     301                 :                         // array: board,thread,postid ==> boardtitle,posttext,userid,posttitle                                                                                                
     302               0 :                         $boards[$post->boardid]['boardName'] = $post->boardname;                                                                                                              
     303               0 :                         $boards[$post->boardid]['isPhotoGallery'] = $post->is_photogallery;                                                                                                   
     304               0 :                         $boards[$post->boardid]['threads'][$post->threadid]['threadTopic'] = $post->threadtopic;                                                                              
     305               0 :                         $boards[$post->boardid]['threads'][$post->threadid]['threadID'] = $post->threadid;                                                                                    
     306               0 :                         $boards[$post->boardid]['threads'][$post->threadid]['lastVisitedTime'] = $post->lastvisitedtime;                                                                      
     307               0 :                         $boards[$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['postid'] = $post->postid;                                                                
     308               0 :                         $boards[$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['postTime'] = $post->posttime;                                                            
     309               0 :                         $boards[$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['postText'] = $post->posttext;                                                            
     310               0 :                         $boards[$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['userID'] = $post->userID;                                                                
     311               0 :                         $boards[$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['postLastEditTime'] = $post->postlastedittime;                                            
     312               0 :                         $this->users[$boards[$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['userID']] =                                                                 
     313               0 :                             $boards[$post->boardid]['threads'][$post->threadid]['posts'][$post->postid]['userID'];                                                                            
     314               0 :                         $postsTotal++;                                                                                                                                                        
     315               0 :                     }                                                                                                                                                                         
     316               0 :                 }                                                                                                                                                                             
     317               0 :                 if ($postsTotal == 0)                                                                                                                                                         
     318               0 :                     $this->news = null;                                                                                                                                                       
     319                 :                 else {                                                                                                                                                                        
     320               0 :                     $this->news["messagesPerPage"] = $db->get_var("SELECT keyvalue FROM forum_registry WHERE keyname='vars_m_amount'");                                                       
     321               0 :                     $this->news["data"] = $boards;                                                                                                                                            
     322               0 :                     $this->news["count"] = $postsTotal;                                                                                                                                       
     323                 :                 }                                                                                                                                                                             
     324               0 :             }                                                                                                                                                                                 
     325               0 :         }                                                                                                                                                                                     
     326                 :                                                                                                                                                                                               
     327               0 :         return $this->news;                                                                                                                                                                   
     328                 :     }                                                                                                                                                                                         
     329                 :     /**                                                                                                                                                                                       
     330                 :      * @see NewsCategory                                                                                                                                                                      
     331                 :      */                                                                                                                                                                                       
     332                 :     protected function echoNewsEntry($entry, $courseID, $usergroup = null)                                                                                                                    
     333                 :     {                                                                                                                                                                                         
     334               0 :         if(!isset($this->dark) || !isset($entry) || !isset($courseID) || !isset($this->news["user"])) return;                                                                                 
     335               0 :         $board = $entry;                                                                                                                                                                      
     336               0 :         if (count($board) > 0 && is_array($board['threads'])) {                                                                                                                               
     337                 :             echo "<tr>"                                                                                                                                                                       
     338                 :                 ."<td colspan='2' class='tableCellHead'>"                                                                                                                                     
     339               0 :                 .($board["isPhotoGallery"] ? "FotoForum: " : "") .Data::toHTML($board["boardName"], false)                                                                                    
     340               0 :                 ."</td>"                                                                                                                                                                      
     341               0 :                 ."</tr>\n";                                                                                                                                                                   
     342                 :                                                                                                                                                                                               
     343               0 :             foreach($board['threads'] as $thread) {                                                                                                                                           
     344                 :                                                                                                                                                                                               
     345               0 :                    $module = (($board["isPhotoGallery"]) ? "photogallery" : "forum");                                                                                                         
     346               0 :                    $link = PATH_TO_ROOT.$module."/showtopic.php?threadid={$thread['threadID']}&amp;time=".$thread['lastVisitedTime'];                                                         
     347                 :                 // aus dem Foyer in einen Kurs                                                                                                                                                
     348               0 :                 if ($courseID && $courseID != $_SESSION["course"]) $link.= "&amp;changeToCourse=$courseID";                                                                                   
     349                 :                 {                                                                                                                                                                             
     350               0 :                        $threadTopic = Data::toHTML($thread["threadTopic"], false);                                                                                                            
     351                 :                                                                                                                                                                                               
     352               0 :                        $g_DiesenThreadlesen = $this->translate->_("Diesen Thread lesen");                                                                                                     
     353               0 :                        $g_Lesen = $this->translate->_("Lesen");                                                                                                                               
     354                 :                                                                                                                                                                                               
     355               0 :                        eval($this->forumThreadTemplate->GetTemplate());                                                                                                                       
     356                 :                 }                                                                                                                                                                             
     357               0 :                 if ( ! isset($postLinkExtra) )                                                                                                                                                
     358               0 :                     $postLinkExtra = "";                                                                                                                                                      
     359               0 :                 foreach($thread['posts'] as $post) {                                                                                                                                          
     360               0 :                     $postLinkExtra.= "&amp;postid=". (int)$post["postid"];                                                                                                                    
     361               0 :                     $userLink = $this->getProfileLink($this->news["user"], $post["userID"], $courseID);                                                                                       
     362               0 :                        $editInfo = ($post["postLastEditTime"] ? " <span style='font-style:italic'>(". $this->translate->_("hat den Beitrag editiert").")</span>" : "");                       
     363               0 :                      if ($post["postLastEditTime"] > 0)                                                                                                                                       
     364               0 :                          $postTime = (int)$post["postLastEditTime"];                                                                                                                          
     365                 :                      else                                                                                                                                                                     
     366               0 :                          $postTime = (int)$post["postTime"];                                                                                                                                  
     367               0 :                        $postTime = Output::echoDate("d.m.Y H:i", (int)$post["postTime"]);                                                                                                     
     368               0 :                       $postText = Data::toHTML(Utilities::chopText($post["postText"], 140), false);                                                                                           
     369               0 :                      if ($role = RoleArtefacts::getRoleForItem($this->myCategory, (int)$post["postid"]))                                                                                      
     370               0 :                       {                                                                                                                                                                       
     371               0 :                            $userLink.= " (".$role->getPropertiesLink($role->getName($this->news[$post["userID"]]["gender"]), $this->translate->_("Rollen-Eigenschaften anzeigen"), true) .")";
     372               0 :                      }                                                                                                                                                                        
     373                 :                                                                                                                                                                                               
     374               0 :                      $g_DiesenBeitraglesen = $this->translate->_("Diesen Beitrag lesen");                                                                                                     
     375               0 :                        $g_Lesen = $this->translate->_("Lesen");                                                                                                                               
     376                 :                                                                                                                                                                                               
     377               0 :                       eval($this->forumThreadPostTemplate->GetTemplate());                                                                                                                    
     378               0 :                 }                                                                                                                                                                             
     379               0 :             }                                                                                                                                                                                 
     380               0 :         }                                                                                                                                                                                     
     381               0 :     }                                                                                                                                                                                         
     382                 : }                                                                                                                                                                                             

Generated by PHPUnit 3.2.21 and Xdebug 2.0.4 at Sat Nov 7 22:04:08 CET 2009.